-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sock_dtls: move common code into sock_dtls_establish_session() #19142
Conversation
394a32f
to
a41ecb4
Compare
a76548a
to
a4f142d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please Squash. I think it is looking good too.
I´ve got a problem with python when setting up dodtls, even though the instructions are pretty detailed. Since you´ve tested it, it should be good.
2acc48a
to
df4ef80
Compare
bors merge |
Build succeeded: |
_cred_type = creds->type; | ||
_cred_tag = creds->tag; | ||
_id = (uint16_t)(random_uint32() & 0xffff); | ||
exit: | ||
memset(_dns_buf, 0, sizeof(_dns_buf)); /* flush-out unencrypted data */ | ||
mutex_unlock(&_server_mutex); | ||
return (res > 0) ? 0 : res; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benpicco: the credman_delete(creds_tag, creds_type);
got removed from line 184 maybe we need that in l. 206 if the connection could not be established since in that case it would not be closed -> that credman slot would be taken until reboot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of what I thought here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missed that
but somehow i am still not fully convinced maybe the credman_delete
in
_close_session
is also wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe that whole file should never call any credman function (but find or get) since the add should be done in another part of RIOT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
credman is weird - it's true that the credentials are only stored for the lifetime of the session.
Since they are added in _connect_server()
they should also be removed if _connect_server()
fails - unless they were already added to credman before.
Same goes for _close_session()
.
Now what I don't get is why credman is needed at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems more like it is not used as intended
intention:
init:
add all your creeds to credman
connect:
use a cred by tag
done here:
connect
add this creed to credman
use the cred just added
but there where applications before that that did the credential handling themself and these are now add cred to credman
and that use the cred
if we use it as intended we would just have one place where all the creds are managed this would make the review of the creds on a device simpler)
seems like the move to cred man is just incomplete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is the reasoning why credman and not just a pointer to credentials
Contribution description
Currently the logic to establish a DTLS session is open-coded in each protocol that uses DTLS (CoAPS, DoDTLS).
To avoid code duplication, move the common code to establish a connection into a
sock_dtls_connect()
helper function that can be shared by it's users.Testing procedure
tests/nanocoap_cli
still works as before, can connect toexamples/gcoap_dtls
server via CoAPStests/gnrc_sock_dodtls
still untestedoutput of gnrc_sock_dodtls
Issues/PRs references